package com.sh.data.engine.application.model.dto.integration;

import com.sh.data.engine.domain.shims.db.model.TableInfoDomain;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import java.util.List;

@Data
@Schema
public class OfflineTaskExistTableMappingResponse {

    @Schema(description = "表列表")
    private List<Table> tables;

    @Data
    @Schema
    public static class Table {

        @NotBlank(message = "表名不能为空")
        @Schema(description = "表名")
        private String tableName;

        /**
         * 表类型
         */
        @Schema(description = "表类型")
        private TableInfoDomain.TblType tblType;

        @Schema(description = "字段列表")
        private List<Field> fields;

        @Schema(description = "分区列表")
        private List<Field> partitionFields;

    }


    @Data
    @Schema
    public static class Field {

        @Schema(description = "关键字")
        private String key;

        @Schema(description = "字段名")
        private String fieldName;

        @Schema(description = "字段类型（从db中读取到的）")
        private String fieldType;

        @Schema(description = "字段类型（对应的java.sql.Types的SQL类型）")
        private Integer dataType;

        @Schema(description = "字段长度")
        private Integer columnSize;

        @Schema(description = "字段小数位长度")
        private Integer decimalDigits;

        @Schema(description = "字段可否为空 0-NO  1-YES")
        private boolean isNullable;

        @Schema(description = "字段默认值")
        private String defaultValue;

        @Schema(description = "是否是分区字段")
        private Boolean isPartition;

        @Schema(description = "字段是否是主键")
        private boolean isPk;

        @Schema(description = "字段备注")
        private String comment;
    }
}
